package JavaGuide;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
class Address implements Cloneable{
    private String name;
    public Address clone() throws CloneNotSupportedException {
        return (Address)super.clone();
    }
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Person implements Cloneable{
    private Address address;
    public Person clone() throws CloneNotSupportedException {
        Person person=(Person)super.clone();
        person.setAddress(person.getAddress().clone());//加上这句就是深拷贝
        return person;
    }
}

public class Clone {
//浅拷贝
    public static void main(String[] args) throws CloneNotSupportedException {
        Person p1=new Person(new Address("武汉"));
        Person clonep=p1.clone();
        System.out.println(p1.getAddress()==clonep.getAddress());

        Class<Person> personClass = Person.class;
        System.out.println(personClass);



    }
}
